<template>
	<view class="container">
		<view class="top">
			<image class="image" src="@/static/morentouxiang.png"></image>
			<text>{{user.nickName}}</text>
		</view>
		<view class="content">
			<uni-collapse ref="collapse" accordion>
				<view v-for="item in list">
					<uni-collapse-item :title="item.schoolYear || '-'" :name="item.schoolYear" :key="item.schoolYear">
						<view class="total">
							<span class="price">已缴: {{ formatNumber(item.payment) }}</span>
							<!-- <span class="price">欠费: {{ item.outstandingAmount }}</span> -->
							<span class="price">合计: {{ item.totalAmount || '-' }}</span>
						</view>
						<view class="content">
							<uni-list-item v-if="item.tuition" showExtraIcon="true" title="学费" :rightText="item.tuition" />
							<uni-list-item v-if="item.hotelExpense" showExtraIcon="true" title="住宿费" :rightText="item.hotelExpense" />
							<uni-list-item v-if="item.textbookFee" showExtraIcon="true" title="教材费" :rightText="item.textbookFee" />
							<uni-list-item v-if="item.militaryExpense" showExtraIcon="true" title="军训费" :rightText="item.militaryExpense" />
							<uni-list-item v-if="item.insurancePremium" showExtraIcon="true" title="保险费" :rightText="item.insurancePremium" />
							<uni-list-item v-if="item.examinationFee" showExtraIcon="true" title="体检费" :rightText="item.examinationFee" />
							<uni-list-item v-if="item.propertyDeposit" showExtraIcon="true" title="财产押金" :rightText="item.propertyDeposit" />
						</view>
					</uni-collapse-item>
				</view>
			</uni-collapse>
		</view>
	</view>
</template>

<script>
	import {
		getUserProfile,
		getStudentRecordList,
	} from "@/api/system/user"
	
	import { formatNumber } from '@/utils/common.js'
	export default {
		data() {
			return {
				user: {},
				list: [
				]
			}
		},
		onLoad() {
			this.getUser(),
			this.getStudentRecordList();
		},
		methods: {
			formatNumber,
			getUser() {
				getUserProfile().then(response => {
					this.user = response.data;
				})
			},
			getStudentRecordList() {
				getStudentRecordList().then(response => {
					console.log(response.data);
					this.list = response.data;
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #ffffff;
	}

	.top {
		margin-bottom: 25rpx;
		padding: 30rpx 50rpx;
		display: flex;
		align-items: center;

		.image {
			width: 80rpx;
			height: 80rpx;
			margin-right: 40rpx;
		}
	}
	.total {
		padding: 0 28rpx 25rpx 28rpx;
		font-size: 24rpx;
		.price {
			padding-right: 30rpx;
		}
	}
	/deep/ .uni-collapse-item__title-text {
		font-weight: bold;
	}
</style>